const path = require("path");
const resolve = (dir) => path.resolve(__dirname, dir);
const sassResourcesLoader = require("craco-sass-resources-loader");

module.exports = {
  style: {
    sass: {
      loaderOptions: {
        sourceMap: true,
      },
    },
  },
  plugins: [
    {
      plugin: sassResourcesLoader,
      options: {
        resources: "./src/assets/css/index.scss",
      },
    },
  ],
  webpack: {
    alias: {
      "@": resolve("src"),
      assets: resolve("src/assets"),
      common: resolve("src/common"),
      components: resolve("src/components"),
      router: resolve("src/router"),
      services: resolve("src/services"),
      store: resolve("src/store"),
      views: resolve("src/views"),
      utils: resolve("src/utils"),
    },
  },
  // devServer: {
  //   host: 'localhost',//target host
  //   port: 5000,
  //   proxy: {
  //     [process.env.REACT_APP_API]: {
  //       target: `${process.env.REACT_APP_BASE_URL}`, //配置你要请求的服务器地址
  //       changeOrigin: true,
  //       pathRewrite: {
  //         [`^${process.env.REACT_APP_API}`]: "",
  //       },
  //     },
  //   },
  // },
  devServer: {
    //这里用变量直接报错
    host: "localhost", //target host
    port: 5000,
    proxy: {
      "/devApi": {
        target: "http://www.web-jshtml.cn/api/react", //配置你要请求的服务器地址
        changeOrigin: true,
        pathRewrite: {
          "/devApi": "",
        },
      },
    },
  },
};
